home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / LPC / types < prev    next >
Text File  |  2001-07-14  |  3KB  |  75 lines

  1. CONCEPT
  2.     types
  3.  
  4. DESCRIPTION
  5.  
  6.     Variables can have the following types:
  7.  
  8.     o int       An integer. Normally full 32 bits signed; ranges
  9.                 are -2,147,483,648 to 2,147,483,648.
  10.                 Integer values can be specified in decimal, in sedecimal when
  11.                 preceeded by '0x' (e.g. 0x11), binary when preceeded by
  12.                 '0b' (e.g. 0b00010001), octal when preceeded by '0o'
  13.                 (e.g. 0o21) and as character yielding the
  14.                 charset value for the character as the number to use (e.g. '0'
  15.                 yields 48 on ASCII machines).
  16.  
  17.     o status    OUTDATED - Status was planned to be an optimized
  18.                 boolean format, but this was never actually
  19.                 implemented. Statas does work; however, since it
  20.                 is only an alias for type 'int', just use int.
  21.  
  22.     o string    Strings in lpc are true strings, not arrays of characters
  23.                 as in C (and not pointers to strings). Strings are
  24.                 mutable -- that is, the contents of a string can be
  25.                 modified as needed. Strings are automatically concatenated
  26.                 by the gamedriver at runtime, so the + operator is no
  27.                 longer strictly necessary to combine two strings.
  28.  
  29.     o object    Pointer to an object. Objects are always passed by
  30.                 reference.
  31.  
  32.     o array     Pointer to a vector of values, which could also
  33.                 be an alist. Arrays take the form ({ n1, n2, n3 })
  34.                 and may contain any type or a mix of types. Arrays
  35.                 are always passed by reference. Note that the size
  36.                 of arrays in LPC, unlike most programming languages,
  37.                 CAN be changed at run-time.
  38.  
  39.     o mapping   An 'associative array' consisting of values indexed by
  40.                 keys. The indices can be any kind of datatype.
  41.                 Mappings take the form ([ key1: value1, key2: value2 ]).
  42.                 By default, mappings are passed by reference.
  43.  
  44.     o closure   References to executable code, both to local
  45.                 functions, efuns and to functions compiled at
  46.                 run-time ("lambda closures").
  47.  
  48.     o symbol    Identifier names, which in essence are quoted strings.
  49.                 They are used to compute lambda closures, e.g. instead
  50.                 of ({..., 'ident, ... }) you can write declare a 
  51.                 'symbol' variable foo, compute a value for it, and then
  52.                 create the closure as ({ ..., foo, ... })
  53.  
  54.     o float     A floating point number. The interpreter must have the
  55.                 floats enabled at compile time.
  56.  
  57.     o mixed     A variable allowed to take a value of any type (int,
  58.                 string, object, array, mapping, float or closure).
  59.  
  60.     All uninitialized variables have the value 0.
  61.  
  62.     The type of a variable is really only for documentation. Unless
  63.     you define #pragma strict_types, variables can actually be of
  64.     any type and has no effect at all on the program. However, it's
  65.     extremely bad style to declare one type but use another, so
  66.     please try to avoid this.
  67.  
  68.     A pointer to a destructed object will always have the value 0.
  69.  
  70.  
  71. SEE ALSO
  72.     alists(LPC), arrays(LPC), mappings(LPC), closures(LPC),
  73.     typeof(E), get_type_info(E), inheritance(LPC), pragma(LPC),
  74.     modifiers(LPC), escape(LPC)
  75.